package com.example.expresscabinet.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.expresscabinet.common.Result;
import com.example.expresscabinet.model.sendexpress;
import com.example.expresscabinet.service.ISendexpressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sendexpress")
public class sendexpressController {
    @Autowired
    ISendexpressService sendexpressService;


    //用户寄件操作
    @GetMapping("/add/{tel}/{num}/{fromWhere}/{fromWhereDetail}/{toWhere}/{toWhereDetail}/{company}")
    public Result<?> add(@PathVariable String tel,
                         @PathVariable int num,
                         @PathVariable String fromWhere,
                         @PathVariable String fromWhereDetail,
                         @PathVariable String toWhere,
                         @PathVariable String toWhereDetail,
                         @PathVariable String company){
        sendexpress res=sendexpressService.addSendexpress(tel,num,fromWhere,fromWhereDetail,toWhere,toWhereDetail,company);
        return Result.success(res);
    }

    //快递员取件
    @GetMapping("/take/{expresstel}/{code}")
    public Result<?> take(@PathVariable String expresstel,
                         @PathVariable String code){
        sendexpressService.takeSendexpress(expresstel,code);
        return Result.success();
    }

    //用户查询寄出快递未取走列表
    @GetMapping("/querynotake/{tel}")
    public Result<?> queryNoTake(@PathVariable String tel,
                                 @RequestParam int pageNum,
                                 @RequestParam int pageSize){
        Page<sendexpress> res=sendexpressService.querynotake(tel,pageNum,pageSize);
        return Result.success(res);
    }

    //用户查询寄出快递已取走列表
    @GetMapping("/querytake/{tel}")
    public Result<?> queryTake(@PathVariable String tel,
                               @RequestParam int pageNum,
                               @RequestParam int pageSize){
        Page<sendexpress> res=sendexpressService.querytake(tel,pageNum,pageSize);
        return Result.success(res);
    }

    //快递员查询自己负责的寄出快递未取走列表
    @GetMapping("/querynotakebyexpressman/{expresstel}")
    public Result<?> queryNoTakebyexpressman(@PathVariable String expresstel,
                                             @RequestParam int pageNum,
                                             @RequestParam int pageSize){
        Page<sendexpress> res=sendexpressService.querynotakebyexpressman(expresstel,pageNum,pageSize);
        return Result.success(res);
    }

    //快递员查询自己负责的寄出快递已取走列表
    @GetMapping("/querytakebyexpressman/{expresstel}")
    public Result<?> queryTakebyexpressman(@PathVariable String expresstel,
                                           @RequestParam int pageNum,
                                           @RequestParam int pageSize){
        Page<sendexpress> res=sendexpressService.querytakebyexpressman(expresstel,pageNum,pageSize);
        return Result.success(res);
    }
}
